package com.ihg.hiex.admin.dao.session;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.admin.entity.dto.OverallEvaluation;
import com.ihg.hiex.entity.session.during.report.SingleScore;
import com.ihg.hiex.entity.session.during.report.SingleSummaryScore;
import com.ihg.hiex.entity.session.during.report.SumScore;

/**
 * 
 * @author dan
 *
 */
@Dao("hibernate")
public interface ReportWritingDao {
    
    /**
     * 
     * @param name
     * @return
     */
    @Query("FROM SingleScore WHERE name = :name ORDER BY singleScore")  
    public List<SingleScore> listSingleScoreByName(@Variable("name") String name);
    
    /**
     * 
     * @param name
     * @return
     */
    @Query("FROM SingleSummaryScore WHERE name = :name ORDER BY score")  
    public List<SingleSummaryScore> listSingleSummaryScore(@Variable("name") String name);
    
    /**
     * 
     * @return
     */
    @Query("FROM SumScore ORDER BY sumScore")
    public List<SumScore> listSumScore();
    
    /**
     * 
     * @param id
     * @return
     */
    @Query("SELECT new com.ihg.hiex.admin.entity.dto.OverallEvaluation(COUNT(*), ss.singleScore) FROM SingleScore ss WHERE ss.sessionCalibrationId = :id GROUP by ss.singleScore ORDER BY singleScore DESC")
    public List<OverallEvaluation> listOverallEvaluation(@Variable("id") Long id);

}
